package com.jiuling.apis.controller;

import com.jiuling.apis.model.Pmodel.Pmenu;
import com.jiuling.apis.service.basic.HomeServiceI;
import com.jswzc.framework.controller.BaseController;
import com.jswzc.framework.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*************************************************************************
 * 版本：         V1.0  
 *
 * 文件名称 ：HomeController.java 描述说明 ：
 * 
 * 创建信息 : create by 刘佳佳 on 2016-6-14 下午3:34:13  修订信息 : modify by ( ) on (date) for ( )
 * 
 * 版权信息 : Copyright (c) 2015 扬州北斗软件有限公司
 **************************************************************************/

@Controller
@RequestMapping("/home")
public class HomeController extends BaseController {
	private static final long serialVersionUID = 1417800463296358902L;

	@Autowired
	private HomeServiceI homeService;

	/**
	 * 跳转首页
	 * @param mv
	 * @return
	 */
	@RequestMapping("toHome")
	public ModelAndView toHome(ModelAndView mv){
		mv.setViewName("main/index_v3");
		return mv;
	}

	/**
	 * 根据用户权限加载左侧菜单数据
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping("showLeftMenu")
	public void showLeftMenu(HttpServletResponse response) throws Exception{
		short identity = (short) getSession().getAttribute("identity");
		List<Pmenu> pmenuList=homeService.showLeftMenuByRole(identity);
		//List<Pmenu> pmenuList=homeService.showLeftMenuByRole(StringUtil.formatSqlIn("1"));
		writeJson(pmenuList, response);
	}




}
